// **********************************************************************
//
// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

// Ice version 3.2.1

package ru.fizteh.fivt.demo.calc;

public final class CalcNumberPrxHelper extends Ice.ObjectPrxHelperBase implements CalcNumberPrx
{
    public ru.fizteh.fivt.demo.ntypes.MyNumber
    add(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y)
        throws ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        return add(x, y, null, false);
    }

    public ru.fizteh.fivt.demo.ntypes.MyNumber
    add(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx)
        throws ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        return add(x, y, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private ru.fizteh.fivt.demo.ntypes.MyNumber
    add(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("add");
                __delBase = __getDelegate();
                _CalcNumberDel __del = (_CalcNumberDel)__delBase;
                return __del.add(x, y, __ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, __cnt);
            }
        }
    }

    public void
    add_async(AMI_CalcNumber_add __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y)
    {
        add_async(__cb, x, y, null, false);
    }

    public void
    add_async(AMI_CalcNumber_add __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx)
    {
        add_async(__cb, x, y, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private void
    add_async(AMI_CalcNumber_add __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx, boolean __explicitCtx)
    {
        if(__explicitCtx &&  __ctx == null)
        {
            __ctx = _emptyContext;
        }
        __cb.__invoke(this, __cb, x, y, __ctx);
    }

    public ru.fizteh.fivt.demo.ntypes.MyNumber
    div(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y)
        throws DivByZeroException,
               ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        return div(x, y, null, false);
    }

    public ru.fizteh.fivt.demo.ntypes.MyNumber
    div(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx)
        throws DivByZeroException,
               ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        return div(x, y, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private ru.fizteh.fivt.demo.ntypes.MyNumber
    div(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws DivByZeroException,
               ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("div");
                __delBase = __getDelegate();
                _CalcNumberDel __del = (_CalcNumberDel)__delBase;
                return __del.div(x, y, __ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, __cnt);
            }
        }
    }

    public void
    div_async(AMI_CalcNumber_div __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y)
    {
        div_async(__cb, x, y, null, false);
    }

    public void
    div_async(AMI_CalcNumber_div __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx)
    {
        div_async(__cb, x, y, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private void
    div_async(AMI_CalcNumber_div __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx, boolean __explicitCtx)
    {
        if(__explicitCtx &&  __ctx == null)
        {
            __ctx = _emptyContext;
        }
        __cb.__invoke(this, __cb, x, y, __ctx);
    }

    public ru.fizteh.fivt.demo.ntypes.MyNumber
    mult(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y)
        throws ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        return mult(x, y, null, false);
    }

    public ru.fizteh.fivt.demo.ntypes.MyNumber
    mult(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx)
        throws ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        return mult(x, y, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private ru.fizteh.fivt.demo.ntypes.MyNumber
    mult(ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx, boolean __explicitCtx)
        throws ru.fizteh.fivt.demo.ntypes.MyNumberFormatException
    {
        if(__explicitCtx && __ctx == null)
        {
            __ctx = _emptyContext;
        }
        int __cnt = 0;
        while(true)
        {
            Ice._ObjectDel __delBase = null;
            try
            {
                __checkTwowayOnly("mult");
                __delBase = __getDelegate();
                _CalcNumberDel __del = (_CalcNumberDel)__delBase;
                return __del.mult(x, y, __ctx);
            }
            catch(IceInternal.LocalExceptionWrapper __ex)
            {
                __handleExceptionWrapper(__delBase, __ex);
            }
            catch(Ice.LocalException __ex)
            {
                __cnt = __handleException(__delBase, __ex, __cnt);
            }
        }
    }

    public void
    mult_async(AMI_CalcNumber_mult __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y)
    {
        mult_async(__cb, x, y, null, false);
    }

    public void
    mult_async(AMI_CalcNumber_mult __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx)
    {
        mult_async(__cb, x, y, __ctx, true);
    }

    @SuppressWarnings("unchecked")
    private void
    mult_async(AMI_CalcNumber_mult __cb, ru.fizteh.fivt.demo.ntypes.MyNumber x, ru.fizteh.fivt.demo.ntypes.MyNumber y, java.util.Map<String, String> __ctx, boolean __explicitCtx)
    {
        if(__explicitCtx &&  __ctx == null)
        {
            __ctx = _emptyContext;
        }
        __cb.__invoke(this, __cb, x, y, __ctx);
    }

    public static CalcNumberPrx
    checkedCast(Ice.ObjectPrx __obj)
    {
        CalcNumberPrx __d = null;
        if(__obj != null)
        {
            try
            {
                __d = (CalcNumberPrx)__obj;
            }
            catch(ClassCastException ex)
            {
                if(__obj.ice_isA("::demo::calc::CalcNumber"))
                {
                    CalcNumberPrxHelper __h = new CalcNumberPrxHelper();
                    __h.__copyFrom(__obj);
                    __d = __h;
                }
            }
        }
        return __d;
    }

    public static CalcNumberPrx
    checkedCast(Ice.ObjectPrx __obj, java.util.Map<String, String> __ctx)
    {
        CalcNumberPrx __d = null;
        if(__obj != null)
        {
            try
            {
                __d = (CalcNumberPrx)__obj;
            }
            catch(ClassCastException ex)
            {
                if(__obj.ice_isA("::demo::calc::CalcNumber", __ctx))
                {
                    CalcNumberPrxHelper __h = new CalcNumberPrxHelper();
                    __h.__copyFrom(__obj);
                    __d = __h;
                }
            }
        }
        return __d;
    }

    public static CalcNumberPrx
    checkedCast(Ice.ObjectPrx __obj, String __facet)
    {
        CalcNumberPrx __d = null;
        if(__obj != null)
        {
            Ice.ObjectPrx __bb = __obj.ice_facet(__facet);
            try
            {
                if(__bb.ice_isA("::demo::calc::CalcNumber"))
                {
                    CalcNumberPrxHelper __h = new CalcNumberPrxHelper();
                    __h.__copyFrom(__bb);
                    __d = __h;
                }
            }
            catch(Ice.FacetNotExistException ex)
            {
            }
        }
        return __d;
    }

    public static CalcNumberPrx
    checkedCast(Ice.ObjectPrx __obj, String __facet, java.util.Map<String, String> __ctx)
    {
        CalcNumberPrx __d = null;
        if(__obj != null)
        {
            Ice.ObjectPrx __bb = __obj.ice_facet(__facet);
            try
            {
                if(__bb.ice_isA("::demo::calc::CalcNumber", __ctx))
                {
                    CalcNumberPrxHelper __h = new CalcNumberPrxHelper();
                    __h.__copyFrom(__bb);
                    __d = __h;
                }
            }
            catch(Ice.FacetNotExistException ex)
            {
            }
        }
        return __d;
    }

    public static CalcNumberPrx
    uncheckedCast(Ice.ObjectPrx __obj)
    {
        CalcNumberPrx __d = null;
        if(__obj != null)
        {
            CalcNumberPrxHelper __h = new CalcNumberPrxHelper();
            __h.__copyFrom(__obj);
            __d = __h;
        }
        return __d;
    }

    public static CalcNumberPrx
    uncheckedCast(Ice.ObjectPrx __obj, String __facet)
    {
        CalcNumberPrx __d = null;
        if(__obj != null)
        {
            Ice.ObjectPrx __bb = __obj.ice_facet(__facet);
            CalcNumberPrxHelper __h = new CalcNumberPrxHelper();
            __h.__copyFrom(__bb);
            __d = __h;
        }
        return __d;
    }

    protected Ice._ObjectDelM
    __createDelegateM()
    {
        return new _CalcNumberDelM();
    }

    protected Ice._ObjectDelD
    __createDelegateD()
    {
        return new _CalcNumberDelD();
    }

    public static void
    __write(IceInternal.BasicStream __os, CalcNumberPrx v)
    {
        __os.writeProxy(v);
    }

    public static CalcNumberPrx
    __read(IceInternal.BasicStream __is)
    {
        Ice.ObjectPrx proxy = __is.readProxy();
        if(proxy != null)
        {
            CalcNumberPrxHelper result = new CalcNumberPrxHelper();
            result.__copyFrom(proxy);
            return result;
        }
        return null;
    }
}
